package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.QuestionsMapper;
import com.tanhua.model.domain.Questions;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author pc
 * @date 2021/11/27
 */
@DubboService
public class QuestionsApiImpl implements QuestionsApi {
    @Autowired
    private QuestionsMapper questionsMapper;



    /**
     * 获取问卷id
     *
     * @param questionId
     * @return
     */
    @Override
    public Integer getQuestionnaireId(String questionId) {
        Questions questions = questionsMapper.selectById(questionId);
        return questions.getQuestionnaireId();
    }

    /**
     * 获取问卷试题
     *
     * @param id
     * @return
     */
    @Override
    public List<Questions> getQuestion(Integer id) {
        LambdaQueryWrapper<Questions> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Questions::getQuestionnaireId, id);
        return questionsMapper.selectList(lqw);
    }
}
